package apis

import (
	"gitee.com/byx_darwin/ncloud-go/core"
	"gitee.com/byx_darwin/ncloud-go/core/net/consts"
)

type TaskInfo struct {
	Region string `json:"region"`
	UUID   string `json:"uuid"` //边缘设备uuid
	Table  int32  `json:"table"`
}
type CreateTaskConditions struct {
	List        []TaskInfo `json:"list"`
	Proxy       string     `json:"proxy"`
	CallbackUrl string     `json:"callback_url,omitempty"`
}

type TaskCreateRequest struct {
	core.NCloudRequest
	CreateTaskConditions
}

func NewTaskCreateRequestWithTaskList(list []TaskInfo, proxy string) *TaskCreateRequest {
	return &TaskCreateRequest{
		NCloudRequest: core.NCloudRequest{
			Path:   "/gateway/task",
			Method: consts.MethodPost,
		},
		CreateTaskConditions: CreateTaskConditions{
			List:  list,
			Proxy: proxy,
		},
	}
}

func NewTaskCreateRequestWithParams(list []TaskInfo, proxy string, callbackUrl string) *TaskCreateRequest {
	return &TaskCreateRequest{
		NCloudRequest: core.NCloudRequest{
			Path:   "/gateway/task",
			Method: consts.MethodPost,
		},
		CreateTaskConditions: CreateTaskConditions{
			List:        list,
			CallbackUrl: callbackUrl,
			Proxy:       proxy,
		},
	}
}

func (r *TaskCreateRequest) SetTcpTaskList(list []TaskInfo) {
	r.List = list
}

func (r *TaskCreateRequest) SetCallbackUrl(callbackUrl string) {
	r.CallbackUrl = callbackUrl
}

type TaskResult struct {
	TaskID string `json:"task_id"`
}
type TaskResponse struct {
	Code    int        `json:"code"`
	Msg     string     `json:"msg"`
	Data    TaskResult `json:"data,omitempty"`
	TrackID string     `json:"track_id"`
}
